// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using System.Data;

namespace SnapObjects.Data
{
    public class SqlParameterToken : SqlToken
    {
        public SqlParameterToken(string text) : base(text)
        {
            if (!Char.IsLetter(text[0]))
            {
                this.Name = text.Substring(1);

                this.IsDelimit = true;
            }
            else
            {
                this.Name = text;
            }
        }

        public string Name { get; }

        public bool IsDelimit { get; }

        public new string Text
        {
            get => _text;
            set => _text = value;
        }

        public ParameterDirection Direction { get; set; }

        public override SqlTokenType Type => SqlTokenType.Parameter;
    }
}
